var data = {
    detail: $store.state.borrow
}

var vm = {
    data() {
        return data
    },
    mounted() {
        if (!$store.getters.borrowing) {
            $router.replace('/loan/action')
        }
    },
    methods: {
        // 确认借款
        loanDo() {
            if (!$store.getters.userPersonalStatus) {
                $toast.show('请先完成个人信息认证')
                this.$router.push('/loan/personal')
            } else if (!$store.getters.userCardIdStatus) {
                $toast.show('请先完成身份信息热证')
                this.$router.push('/loan/cardid')
            } else {
                $loading.show()
                $ajax.order.borrowSubmit({
                    userId: $store.state.user.userId
                }).then(res => {
                    var { msg, code, data } = res.data
                    $toast.show(msg)
                    if (code == 'S') {
                        if (data.status == 1) {
                            // 首次借款，银行卡未绑定
                            $router.push({ name: 'loan_bankcard' })
                        } else if (data.status == 2) {
                            this.$refs.signForm.submit()
                        }
                    }
                }).catch(err => {
                    $toast.show('网络异常，请稍后重试')
                })
            }
        },
        // 取消借款
        cancelLoanDo() {
            // 返回首页
            $store.dispatch('borrowClear')
            $router.replace('/loan/action')
        }
    },
    mixins: [$mixins.needLogin]
}

export default vm